<%@page import="Modelo.Querys"%>
<%@page import="Controlador.ConnectionDB"%>
<%@page pageEncoding="UTF-8" %>
<% 
String TypeMessage="info";
String FinalMessage = "Vulnerabilidad creada exitosamente!";
String VulnerabilityName = Querys.DecodeString(request.getParameter("VulnerabilityName"));
String VulnerabilityDescription = Querys.DecodeString(request.getParameter("VulnerabilityDescription"));
String VulnerabilityPercent = Querys.DecodeString(request.getParameter("VulnerabilityPercent"));
ConnectionDB c = new ConnectionDB();
if(c.Connect()){
    int r = c.getUpdate("insert into Vulnerability (Name, Description, Percentage) values ('"+VulnerabilityName+"','"+VulnerabilityDescription+"',"+VulnerabilityPercent+");");
    System.out.println("insert into Vulnerability (Name, Description, Percentage) values ('"+VulnerabilityName+"','"+VulnerabilityDescription+"',"+VulnerabilityPercent+");");
    if(r>0){
        c.commit(true);
    }else{
        FinalMessage = "No se pudo ingresar los datos";
        TypeMessage = "error";
    }
    c.close();
}else{
    FinalMessage = "No se pudo conectar a la base de datos.";
    TypeMessage = "error";
}
%>
<jsp:forward page="create_vulnerability.jsp">
    <jsp:param name="FinalMessage" value="<%=FinalMessage%>" />  
    <jsp:param name="TypeMessage" value="<%=TypeMessage %>"/>  
</jsp:forward>